package com.chen10.cattle.mapper;

import com.chen10.cattle.model.pojo.Cattle;
import com.chen10.cattle.model.pojo.DeathCattle;
import com.chen10.cattle.model.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author Administrator
 * @description 针对表【cattle】的数据库操作Mapper
 * @createDate 2025-03-16 19:55:17
 * @Entity com.chen10.cattle.model.pojo.Cattle
 */
@Mapper
public interface CattleMapper {
        int insert(Cattle cattle);

        int update(Cattle cattle);

        int deleteById(int id);

        Cattle selectById(int id);

        Cattle selectByEarTag(String earTag);

        List<CattleListVO> selectAll();

        List<Cattle> searchByCondition(@Param("earTag") String earTag,
                        @Param("name") String name);

        List<Cattle> selectByPage(@Param("offset") int offset,
                        @Param("pageSize") int pageSize);

        // CattleMapper.java
        List<TemperatureHistoryVO> selectTemperatureHistory(
                        @Param("cattleId") Long cattleId,
                        @Param("offset") Integer offset,
                        @Param("pageSize") Integer pageSize);

        int countTemperatureHistory(@Param("cattleId") Long cattleId);

        // CattleMapper.java 新增方法
        // CattleMapper.java
        List<WeightHistoryVO> selectWeightHistory(
                        @Param("cattleId") Long cattleId,
                        @Param("offset") Integer offset,
                        @Param("pageSize") Integer pageSize);

        int countWeightHistory(@Param("cattleId") Long cattleId);

        // 在Mapper接口中添加
        List<LocationHistoryVO> selectLocationHistory(
                        @Param("cattleId") Long cattleId,
                        @Param("offset") Integer offset,
                        @Param("pageSize") Integer pageSize);

        int countLocationHistory(@Param("cattleId") Long cattleId);

        int countSicknessHistory(@Param("cattleId") Long cattleId);
        
        // 添加不分页查询方法
        List<SicknessHistoryVO> selectSicknessHistoryNoPaging(@Param("cattleId") Long cattleId);

        // 添加获取全部牛只详细信息的方法
        CattleDetailVO selectCattleDetail(@Param("cattleId") Long cattleId);


        // 添加获取所有牛只生病记录的方法
        List<SicknessHistoryVO> selectAllSicknessHistoryNoPaging();

        int countAllSicknessHistory();

        // 添加死亡/出栏记录
        int insertDeathCattle(DeathCattle deathCattle);

        // 获取所有牛只（包括已出栏的）
        List<CattleManagementVO> selectAllCattleWithDeathInfo();

        /**
         * 更新牛只状态
         * 
         * @param cattle 牛只对象
         * @return 影响的行数
         */
        int updateCattleStatus(Cattle cattle);
}
